package scala.examples.tcpoly.idioms;

trait Functor[m[_], a] {
	def fmap[b](f: a => b): m[b]
}

trait Functors { 
  implicit def ListIsFunctor[a](l: List[a]): Functor[List, a] = new Functor[List, a] {
    def fmap[b](f: a => b): List[b] = l match {
      case Nil => Nil
      case x :: xs => f(x) :: xs.fmap(f)
    }
  }
}